﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sharp.Domain.Model;

namespace Sharp.Domain.PlatformBoundedContext.PermissionModule.Aggregates
{
    /// <summary>
    /// 权限
    /// </summary>
    public partial class AvailablePermission : IAggregateRoot
    {
        /// <summary>
        /// 权限
        /// </summary>
        public AvailablePermission()
        {
        }
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Guid Id { get; set; }
        /// <summary>
        /// 代码
        /// </summary>
        [Display(Name = "代码")]
        public string Code { get; set; }

        /// <summary>
        ///     标题
        /// </summary>
        [Display(Name = "标题")]
        public string Title { get; set; }

        /// <summary>
        /// 分类
        /// </summary>
        [Display(Name = "权限类型")]
        public string Category { get; set; }

        /// <summary>
        ///     父id
        /// </summary>
        /// <value>父Id</value>
        public System.Guid? ParentId { get; set; }

        /// <summary>
        ///     排序索引
        /// </summary>
        /// <value>排序的值</value>
        public int OrderIndex { get; set; }

        /// <summary>
        ///     程序路由
        /// </summary>
        public string Route { get; set; }

        /// <summary>
        /// 图标或者是css class的名称
        /// </summary>
        public string Ico { get; set; }

        /// <summary>
        /// 系统代号
        /// </summary>
        public string SystemCode { get; set; }
        /// <summary>
        /// 模块id
        /// </summary>
        public string ModuleId { get; set; }

        /// <summary>
        /// 是否为快捷方式
        /// </summary>
        [NotMapped]
        public bool IsShortcut { get; set; }
        [NotMapped]
        public object ForFieldPermission { get; set; }

        public Guid BuildId()
        {
            return Guid.Parse($"{Code}_{SystemCode}_{Category}".Md5());
        }

    }
}